package study.javabasic.communication.pipe;

import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

/**
 * Created by zhangshuhan on 2019/3/21.
 */
public class Test {

    public static void main(String[] args) throws IOException {
        ReadData readData=new ReadData();

        WriteData writeData=new WriteData();
        PipedInputStream in=new PipedInputStream();

        PipedOutputStream out=new PipedOutputStream();
            out.connect(in);

        Thread a=new Thread(new ThreadB(in,readData));


        Thread b=new Thread(new ThreadA(out,writeData));
        b.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        a.start();


    }
}
